package com.zyg.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zyg.pojo.Class;
import com.zyg.pojo.Grade;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClassMapper extends BaseMapper<Class> {
    @Select("SELECT c.class_id, c.class_name,g.grade_name FROM class c JOIN grade g ON c.grade_id = g.grade_id where 1=1")
    @Results(id = "ClassMapper", value = {
            @Result(property = "classId", column = "class_id"),
            @Result(property = "className", column = "class_name"),
            @Result(property = "grade", column = "grade_id",
                    javaType = Grade.class,
                    one = @One(select = "getGrade")),
    })
    List<Class> findAll();
}